*** Settings ***
Documentation    TC07-Routing Confirmation AIR
Resource    ../../Keywords/Common_Head.robot
Resource    ../../Keywords/Common/Common_kw.robot
Force Tags    P1
Metadata    Author     Terence
Metadata    ID    14684
Test Timeout    3600

Test Teardown    Run Keywords    Run Keyword And Ignore Error    Delete Project    ${G_TENDERID}
...    AND    Run Keyword And Ignore Error    Delete Tender    ${G_TENDERID}
...    AND    CloseSpace
...    AND    Set Global Variable    ${USERNAME}    AUTOTEST

*** Variables ***

*** Test Cases ***
TC07-Routing Confirmation AIR
    Step 1 User Goes To Basic Data Management Tender List
    Step 2 User Goes To Pricing Collaboration Pricing Project
    Step 3 Input Following Attributes
    Step 4 User Selects Row That Project Name Is 20240815 AIR
    Step 5 Click On Copy Data
    Step 6 Input Tender ID With Value 2024000001 Click On Search
    Step 7 Select This Entry Click On Copy Data Button And Yes In
    Step 8 Select Current Project In Pricing Project Click On
    Step 9 Click Skip Button In Step4 and Yes In The Pop up
    Step 10 User Clicks Next Round Management Button
    Step 11 User Clicks Routing Confirmation Button
    Step 12 User Clicks APAC To Check the Others Uncheck And Clicks
    Step 13 User Clicks NAM To Check and Others Uncheck And Clicks
    Step 14 User Clicks Europe To Check and Others Uncheck And
    Step 15 User Clicks Setup Button
    Step 16 User Clicks Download Button
    Step 17 User Opens The Download File
    Step 18 User Modifies The Value Of The File Some Columns Are
    Step 19 User Uploads The Modified File
    Step 20 User Clicks Ok Button Of The Pop up Dialogue
    Step 21 User Clicks Setup Button And Download Button
    Step 22 User Opens The Download File 22
    Step 23 User Start Round The Project Assignment Are As APAC
    Step 24 Reopen The Dialog Exchange The Current Role To Regional
    Step 25 User Clicks Routing Confirmation Button 25
    Step 26 The Value And Background Color Are As
    Step 27 Click On OK Button
    Step 28 Select APAC Click On Confirm Button And Approve Button
    Step 29 Select APAC Click On Download Check The Downloaded File
    Step 30 Close This Dialog In Round Management Page Download IPT
    Step 31 Login As NATZHANG Open This Project Round Management
    Step 32 Modify It As
    Step 33 Login As WENDJIAN Again Open This Project Round
    Step 34 Close This Window In Round Management Download IPT
    Step 35 Click On Close Button
    Step 36 Select This Project Click On Delete Project Button
    Step 37 User Goes To Basic Data Management Tender List 37



*** Keywords ***
Step ${step} User Goes To Basic Data Management Tender List
    #************************Step 1******************************
    #  Do:
    #      User goes to Basic Data Management Tender List
    #      Click Create button
    #      Input with following attributes
    #      Tender ID some numbers such as 202408151435001 you can
    #     input with current datetime and some random number to
    #     avoid duplicate validation
    #      Tender Title some value such as Regression Test by
    #     Wendy001
    #      Customer 815 Miele
    #      Mode select all
    #      Level Global
    #      Click on Save button
    #  Expected:
    #      Created successfully with the message Tender has been
    #     added
    #************************************************************
    Login Space
    ${G_TENDERID}    Generate Tender ID
    ${TenderTitle}   Set Variable    Regression Test by Wendy001
    Set Suite Variable     ${G_TENDERID}    ${G_TENDERID}
    Set Suite Variable     ${TenderTitle}    ${TenderTitle}
    Create Tender    ${G_TENDERID}    ${TenderTitle}    815    true    true    true

Step ${step} User Goes To Pricing Collaboration Pricing Project
    #************************Step 2******************************
    #  Do:
    #      User goes to Pricing Collaboration Pricing Project
    #      User clicks Create Project button
    #  Expected:
    #      A New Project dialog should be opened successfully
    #************************************************************
    Log    Finish in next step

Step ${step} Input Following Attributes
    #************************Step 3******************************
    #  Do:
    #      Input following attributes
    #      Tender ID 20240815 Regression
    #      Mode Air
    #      Deadline to TM current date 10 day
    #      Rate Validity From current date
    #      Rate Validity To current date 100 day
    #      Deputies NATZHANG
    #      Description for regression
    #      Click on Save button
    #  Expected:
    #      A new project is created successfully
    #************************************************************
    ${DeadLine}    Get Current Date    UTC    +10days    result_format=%d/%m/%Y
    ${ValidFrom}    Get Current Date    UTC    result_format=%d/%m/%Y
    ${ValidTo}    Get Current Date    UTC    +100days    result_format=%d/%m/%Y
    ${PROJECT}    Copy Dictionary    ${PROJECT_PARAM}
    Set To Dictionary    ${PROJECT}    
    ...    TENDER_ID=${G_TENDERID}    TENDER_TITLE=${TenderTitle}    CUSTOEMR_NAME=Miele    CUSTOMER_LEVEL=Global
          ...   MODE=AIR    DEADLINE_TM_DATE=${DeadLine}    VALID_FROM=${ValidFrom}    VALID_TO=${ValidTo}    DEPUTY=NATZHANG
    Set Test Variable    ${PROJECT}    ${PROJECT}
    Create Project    ${PROJECT}


Step ${step} User Selects Row That Project Name Is 20240815 AIR
    #************************Step 4******************************
    #  Do:
    #      User selects row that project name is 20240815 AIR
    #     Regression
    #  Expected:
    #      The row can be selected successfully
    #************************************************************
    Search Project    ${PROJECT.TENDER_ID}

Step ${step} Click On Copy Data
    #************************Step 5******************************
    #  Do:
    #      Click on Copy Data
    #  Expected:
    #      A dialogue named Copy Target to Project 20240815 AIR
    #     Regression display
    #      Search Criteria
    #      Mode with value AIR uneditable
    #      Customer name with no value
    #      Tender ID with value ALL Editable
    #      Tender Lead with value ALL Editable
    #      RFQ Launch Date with value DD MM YYYY Editable
    #      Search button
    #      Result list has no entry present
    #      Copy Data button is disable now
    #************************************************************
    # Click    ${Project_toolbar_CopyData}
    # Wait For Elements State    //h4[contains(text(),"Copy Target Project To")]
    # Wait For Elements State    //legend[contains(text(),"Search Criteria")]
    # Get Text    ${Project_CopyData_Mode}/option[@selected="selected"]    ==    AIR
    # Get Attribute    ${Project_CopyData_Customer Name}    placeholder    ==    ${EMPTY}
    # Get Attribute    ${Project_CopyData_TenderID}    placeholder    ==    ALL
    # Get Attribute    ${Project_CopyData_TenderLead}    placeholder    ==    ALL
    # Get Attribute    ${Project_CopyData_RFQLaunchDate}    placeholder    ==    DD/MM/YYYY
    # Wait For Elements State    ${Project_CopyData_SearchButton}
    # Wait For Elements State    ${Project_CopyData_CopyDataButton}
    # Get Attribute    ${Project_CopyData_CopyDataButton}    disabled    ==    disabled
    # Wait For Elements State    ${Project_CopyData_Noentrypresent}
    Copy Data    2024000001    AIR    do not touch me

Step ${step} Input Tender ID With Value 2024000001 Click On Search
    #************************Step 6******************************
    #  Do:
    #      Input Tender ID with value 2024000001 click on Search
    #     button
    #  Expected:
    #      index php attachments get bbed6818 f35c 4750 983e
    #     8bad0a53a928 Result list has one entry as above
    #     information
    #************************************************************
    # Fill Text    ${Project_CopyData_TenderID}    2024000001
    # Click    ${Project_CopyData_SearchButton}
    Log    finish in last step

Step ${step} Select This Entry Click On Copy Data Button And Yes In
    #************************Step 7******************************
    #  Do:
    #      Select this entry click on Copy Data button and Yes in
    #     pop up window
    #  Expected:
    #      Successfully with messages in pop up window
    #      Tender has been successfully copied from 2024000001 AIR
    #     do not touch me
    #      Please adjust the template and the lanes in Template
    #     Lane Management page if required
    #      After click on OK button
    #      The same message is displayed in Pricing Project page
    #     too
    #************************************************************
    # Wait For Elements State    //td[.="do not touch me"]
    # Click    //td[.="do not touch me"]
    # Click    ${Project_CopyData_CopyDataButton}
    # Click    ${Dialog_yesButton}
    # Wait For Elements State    //span[contains(text(),"Tender has been successfully copied from [2024000001-AIR-do not touch me].")]
    # Wait For Elements State    //span[contains(text(),"Please adjust the template and the lanes in Template / Lane Management page if required.")]
    # Click    //button[span[.="OK"]]
    # Wait For Elements State    //span[contains(text(),"Tender has been successfully copied from [2024000001-AIR-do not touch me]. Please adjust the template and the lanes in Template / Lane Management page if required.")]
    Log    finish in last step

Step ${step} Select Current Project In Pricing Project Click On
    #************************Step 8******************************
    #  Do:
    #      Select current project in pricing project click on
    #     template management button
    #  Expected:
    #      In the dialog check the information under Step2 should
    #     be the same as project 2024000001 AIR do not touch me
    #************************************************************
    Click    //td[contains(text(),"${G_TENDERID}")]
    Click    ${Project_toolbar_TemplateManagementButton}
    #it has too many fields in dialog and did not check specific fields information for 2024000001 in privous step

Step ${step} Click Skip Button In Step4 and Yes In The Pop up
    #************************Step 9******************************
    #  Do:
    #      Click Skip button in Step4 and Yes in the pop up
    #     windown
    #  Expected:
    #      Next Round Management button is enable
    #************************************************************
    Click    //button[.="Skip"]
    Wait For Elements State    //span[contains(text(),"Are you sure to skip push pricing?")]
    Click    ${Dialog_yesButton}
    Sleep    2
    Wait For Elements State    //button[contains(text(),"Next: Round Management")]    enabled

Step ${step} User Clicks Next Round Management Button
    #************************Step 10******************************
    #  Do:
    #      User clicks Next round management button
    #  Expected:
    #      A dialogue named Project 20240815 AIR Regression Round1
    #     display
    #      We use KIKIXIA1 to login The current role is project
    #     owner
    #      It divides into 5 parts
    #      1 Generation Information current Pricing Round 1
    #     Started 2 lanes
    #      2 Assignment
    #      3 Attached Document
    #      4 Round History
    #      5 The tasks status Region Country My tasks
    #************************************************************
    Click    //button[contains(text(),"Next: Round Management")]
    Wait For Elements State    //h4/span[contains(text(),"Project ${G_TENDERID}-AIR-${TenderTitle}")]
    Wait For Elements State    //legend[.="Generation Information"]
    Wait For Elements State    //legend[.="Assignment"]
    Wait For Elements State    //legend[.="Attached Document"]
    Wait For Elements State    //legend[.="Round History"]
    Wait For Elements State    //a[.="Region"]
    Wait For Elements State    //a[.="My Tasks"]

Step ${step} User Clicks Routing Confirmation Button
    #************************Step 11******************************
    #  Do:
    #      User clicks routing confirmation button
    #  Expected:
    #      A dialogue named routing confirmation appears
    #      On the top there are three buttons download confirm
    #     setup
    #      The confirm button is gray
    #      There are three checkbox region APAC Europe NAM
    #      The status of the region is not reviewed
    #************************************************************
    Wait For Elements State    ${Project_RoundMgmt_RoutConfirmButton}    enabled    30
    Click    ${Project_RoundMgmt_RoutConfirmButton}
    Wait For Elements State    ${Project_RoundMgmt_Routing_Confirm}    visible    60
    Get Element States    ${Project_RoundMgmt_Routing_Confirm}    contains    disabled
    Wait For Elements State    //td[.="APAC"]
    Wait For Elements State    //td[.="APAC"]/../td[.="Not Reviewed"]
    Wait For Elements State    //td[.="NAM"]
    Wait For Elements State    //td[.="NAM"]/../td[.="Not Reviewed"]
    Wait For Elements State    //td[.="EUROPE"]
    Wait For Elements State    //td[.="EUROPE"]/../td[.="Not Reviewed"]

Step ${step} User Clicks APAC To Check the Others Uncheck And Clicks
    #************************Step 12******************************
    #  Do:
    #      User clicks APAC to check the others uncheck and clicks
    #     download
    #  Expected:
    #      The file can download successfully
    #      Open the file and it has two lanes
    #************************************************************
    Click    xpath=//div//tr[td//text()[contains(.,"APAC")]]//input[@type='checkbox']
    ${filename}    Download File    ${Project_RoundMgmt_Routing_Download}
    Wait Until Keyword Succeeds    3x    500ms    Open Excel Document     ${filename}    ${PROJECT.MODE}
    ${landInfo}    Read Excel Column    1
    ${rowCount}    Get Length    ${landInfo}
    Should Be Equal As Integers    ${rowCount}    3   ##there are three rows incldued column title
    Close Current Excel Document
    Remove File    ${filename}


Step ${step} User Clicks NAM To Check and Others Uncheck And Clicks
    #************************Step 13******************************
    #  Do:
    #      User clicks NAM to check and others uncheck and clicks
    #     download
    #  Expected:
    #      The file can download successfully
    #      Open the file and it has only one lane
    #************************************************************
    Click    xpath=//div//tr[td//text()[contains(.,"APAC")]]//input[@type='checkbox']
    Click    xpath=//div//tr[td//text()[contains(.,"NAM")]]//input[@type='checkbox']
    ${filename}    Download File    ${Project_RoundMgmt_Routing_Download}
    Open Excel Document     ${filename}    ${PROJECT.MODE}
    ${landInfo}    Read Excel Column    1    
    ${rowCount}    Get Length    ${landInfo}
    Should Be Equal As Integers    ${rowCount}    2   ##there are three rows incldued column title
    Close Current Excel Document
    Remove File    ${filename}

Step ${step} User Clicks Europe To Check and Others Uncheck And
    #************************Step 14******************************
    #  Do:
    #      User clicks Europe to check and others uncheck and
    #     clicks download
    #  Expected:
    #      The file can download successfully
    #      Open the file and it has only one lane
    #************************************************************
    Click    xpath=//div//tr[td//text()[contains(.,"NAM")]]//input[@type='checkbox']
    Click    xpath=//div//tr[td//text()[contains(.,"EUROPE")]]//input[@type='checkbox']
    ${filename}    Download File    ${Project_RoundMgmt_Routing_Download}
    Open Excel Document     ${filename}    ${PROJECT.MODE}
    ${landInfo}    Read Excel Column    1       
    ${rowCount}    Get Length    ${landInfo}
    Should Be Equal As Integers    ${rowCount}    2   ##there are two rows incldued column title
    Close Current Excel Document
    Remove File    ${filename}

Step ${step} User Clicks Setup Button
    #************************Step 15******************************
    #  Do:
    #      User clicks setup button
    #  Expected:
    #      A dialogue named routing confirmation setup appears
    #************************************************************
    Click    ${Project_RoundMgmt_Routing_Setup}
    Wait For Elements State    ${Project_RoundMgmt_Setup_Download}    visible    10

Step ${step} User Clicks Download Button
    #************************Step 16******************************
    #  Do:
    #      User clicks download button
    #  Expected:
    #      The file download successfully
    #      The name of the file likes that RoutingSetupFile
    #************************************************************
    ${filename}    Download File    ${Project_RoundMgmt_Setup_Download}
    Set Test Variable    ${filename}     ${filename} 

Step ${step} User Opens The Download File
    #************************Step 17******************************
    #  Do:
    #      User opens the download file
    #  Expected:
    #      There are two lanes in the file It has five columns
    #     Lane Id Origin Airport Origin Gateway Destination
    #     Gateway Destination Airport
    #      The detail you can see from the screenshot
    #************************************************************
    ${RoutingFileColumn}    Create List    Lane ID    Origin Airport    Origin Gateway    Destination Gateway    Destination Airport
    Set Suite Variable    ${ROUTING_FILE_COLUMN}    ${RoutingFileColumn}
    Open Excel Document     ${filename}    Sheet0
    ${titleList}    Read Excel Row    1
    Lists Should Be Equal    ${titleList}    ${ROUTING_FILE_COLUMN}    ignore_order=True
    ${laneInfo}    Read Excel Column    1       
    ${rowCount}    Get Length    ${laneInfo}
    Should Be Equal As Integers    ${rowCount}    3   ##there are three rows incldued column title
    Close Current Excel Document
    Open Excel Document     ${filename}    Sheet0

Step ${step} User Modifies The Value Of The File Some Columns Are
    #************************Step 18******************************
    #  Do:
    #      User modifies the value of the file Some columns are
    #     allowed and some are not allowed
    #  Expected:
    #      The file can modify successfully For example like below
    #************************************************************
    Write Excel Cell    2    2    Not Allowed    Sheet0
    Write Excel Cell    3    2    Not Allowed    Sheet0
    Save Excel Document    ${filename}
    Close Current Excel Document
    Sleep    2

Step ${step} User Uploads The Modified File
    #************************Step 19******************************
    #  Do:
    #      User uploads the modified file
    #  Expected:
    #      There is a pop up dialogue telling you uploaded
    #     successfully
    #************************************************************
    Click    ${Project_RoundMgmt_Setup_Upload}
    Wait For Elements State    ${Project_RoundMgmt_Setup_UploadAddFile}    visible    60
    Wait For Elements State   ${Project_RoundMgmt_Setup_UploadAddFile}     enabled
    Upload File By Selector    ${upload_addFileButton}    ${filename}
    Wait Until Search Finished

Step ${step} User Clicks Ok Button Of The Pop up Dialogue
    #************************Step 20******************************
    #  Do:
    #      User clicks ok button of the pop up dialogue
    #  Expected:
    #      The pop up disappears
    #************************************************************
    Wait For Elements State    ${Project_RoundMgmt_Setup_UploadAddFile_OKButton}    visible    60
    Click    ${Project_RoundMgmt_Setup_UploadAddFile_OKButton}
    Remove File    ${filename}
    Sleep    2


Step ${step} User Clicks Setup Button And Download Button
    #************************Step 21******************************
    #  Do:
    #      User clicks setup button and download button
    #  Expected:
    #      A file download successfully
    #************************************************************
    Click    ${Project_RoundMgmt_Routing_Setup}
    ${filename}    Download File    ${Project_RoundMgmt_Setup_Download}
    Set Test Variable    ${filename}     ${filename}

Step ${step} User Opens The Download File 22
    #************************Step 22******************************
    #  Do:
    #      User opens the download file
    #  Expected:
    #      The value of the file is equal to the modified value
    #************************************************************
    Open Excel Document     ${filename}    Sheet0
    Check Cell Value    2    2    Not Allowed    Sheet0
    Check Cell Value    3    2    Not Allowed    Sheet0   
    Close All Excel Documents
    Remove File     ${filename}
    Click    ${Dialog_Close}
    Click    ${Dialog_Close}
    Sleep    1
    Click    ${Project_RoundMgmt_Routing_Close}

Step ${step} User Start Round The Project Assignment Are As APAC
    #************************Step 23******************************
    #  Do:
    #     set deadline for each region: APAC->current date +5 day, Europe-->current date +5 day, NAM-->current date +5 day
    #     Set user assignee for each region: APAC->WENDJIAN, Europe-->NATZHANG, NAM-->ZLAWRENC
    #     Start round. Send notification.
    #  Expected:
    #      Round start successfully
    #************************************************************
    ${date}    Get Current Date    increment=+5    result_format=%d/%m/%Y
    Input Deadline In Region Tab    0    0    ${date}
    Input Deadline In Region Tab    0    1    ${date}
    Input Deadline In Region Tab    1    0    ${date}

    Wait Until Keyword Succeeds    5x    100ms    Click    ${Project_RoundMgmt_AssignButton}
    Wait For Elements State    ${Project_RoundMgmt_Assign_ApacTab}    visible    
    Click    xpath= //div[@data-model='selectedItems']
    Round Mgmt Assign User    ${Project_RoundMgmt_Assign_ApacTab}    xpath=//div[@data-model='availableItems']//ul//li//b[.='Wendy Jiang (WENDJIAN)']
    Round Mgmt Assign User    ${Project_RoundMgmt_Assign_EuropeTab}    xpath= //div[@class='tab-pane ng-scope active']//div[@class='tab-pane ng-scope active']//b[.='natural zhang (NATZHANG)']
    Round Mgmt Assign User    ${Project_RoundMgmt_Assign_NamTab}    xpath =//div[@class='tab-pane ng-scope active']//div[@class='tab-pane ng-scope active']//b[.='Lawrence Zheng (ZLAWRENC)']
    Click    ${Project_RoundMgmt_Assign_SaveButton}
    Wait Until Search Finished
    Click    ${Project_RoundMgmt_StartButton}
    Wait Until Keyword Succeeds    10x    100ms    Click    ${Project_RoundMgmt_StartConfirmButton} 
    Wait Until Search Finished
    Wait Until Keyword Succeeds    20x    100ms    Click    ${Project_RoundMgmt_Confirm_SendButton}
    Wait Until Search Finished
    Close Browser

Step ${step} Reopen The Dialog Exchange The Current Role To Regional
    #************************Step 24******************************
    #  Do:
    #      Reopen the dialog exchange the current role to Regional
    #     Pricing Manager APAC
    #  Expected:
    #      Role exchanged successfully
    #************************************************************
    # Round Review    WENDJIAN
    Remove All Files
    Set Global Variable    ${USERNAME}    WENDJIAN
    Login Space
    Search Project    ${PROJECT.TENDER_ID}
    Wait Until Search Finished
    Wait Until Keyword Succeeds    10x    500ms    Click    ${Project_toolbar_RoundMgmtButton}
    # Wait For Elements State    ${Project_RoundMgmt_CurrentRole}    enabled    60
    Wait For Elements State    //div[@ng-click="toggleDropdown()"]
    Click    //div[@ng-click="toggleDropdown()"]
    Click    //div[contains(text(),"Regional Pricing Manager(APAC)")]

Step ${step} User Clicks Routing Confirmation Button 25
    #************************Step 25******************************
    #  Do:
    #      User clicks routing confirmation button
    #      Pop up window Routing Confirmation displayes
    #      Note Please only review the ports which have been
    #     marked in ORANGE All other ports can be updated by
    #     pricing lead only
    #      There are 2 lanes need your confirmation please
    #     download the list and upload it after confirming
    #      download Upload Cancel button
    #      Click Download button
    #  Expected:
    #      Download file successfully
    #************************************************************
    Click    ${Project_RoundMgmt_RoutConfirmButton}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_Download}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_Upload}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_Cancel}
    ${filename}    Download File    ${Project_RoundMgmt_Confirm_Download}
    Set Test Variable    ${filename}    ${filename}
    Wait Until Search Finished

    Open Excel Document     ${filename}    Sheet0
    ${laneInfo}    Read Excel Column    1       
    ${rowCount}    Get Length    ${laneInfo}
    Should Be Equal As Integers    ${rowCount}    3   ##there are three rows incldued column title


Step ${step} The Value And Background Color Are As
    #************************Step 26******************************
    #  Do:
    #      The value and background color are as
    #      index php attachments get 4fabcc50 ce85 4010 a4d1
    #     dc54f9dc9b8b
    #      Modify the download file
    #      lane1 origin airport SHE to SHA
    #      lane2 Destination Gateway SYD to AUU Destination
    #     Airport SYD to AUU
    #      Then upload the file
    #  Expected:
    #      Uploaded Successfully is displayed
    #************************************************************
    Write Excel Cell    2    13    SHA    AIR
    Write Excel Cell    3    15    AUU    AIR
    Write Excel Cell    3    16    AUU    AIR
    Save Excel Document    ${filename}
    Close Current Excel Document
    Click     ${Project_RoundMgmt_Confirm_Upload}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_UploadAddFile}    visible    10
    Upload File By Selector    ${upload_addFileButton}    ${filename}
    Wait Until Search Finished

Step ${step} Click On OK Button
    #************************Step 27******************************
    #  Do:
    #      Click on OK button
    #      Exchange current role to Project owner
    #      User clicks round button routing confirmation button
    #  Expected:
    #      The state of the APAC region is reviewed
    #************************************************************
    Wait For Elements State    ${Project_RoundMgmt_Setup_UploadAddFile_OKButton}    visible    60
    Click    ${Project_RoundMgmt_Setup_UploadAddFile_OKButton}
    Remove File   ${filename}

    Close Browser
    Remove File    ${filename}
    Set Global Variable    ${USERNAME}    AUTOTEST
    Login Space
    Search Project    ${PROJECT.TENDER_ID}
    Wait Until Search Finished
    Click    ${Project_toolbar_RoundMgmtButton}
    Wait For Elements State    ${Project_RoundMgmt_RoutConfirmButton}     enabled    60
    Click    ${Project_RoundMgmt_RoutConfirmButton}
    Wait For Elements State   ${Project_RoundMgmt_Routing_Download}    enabled    60
    Get Element States     xpath=//div//tr[td//text()[contains(.,"APAC")]][td//text()[contains(.,"Reviewed")]]    contains    visible

Step ${step} Select APAC Click On Confirm Button And Approve Button
    #************************Step 28******************************
    #  Do:
    #      Select APAC click on confirm button and Approve button
    #  Expected:
    #      The state of the APAC region is Confirmed
    #************************************************************
    Click    xpath=//div//tr[td//text()[contains(.,"APAC")]]//input[@type='checkbox']
    Click    ${Project_RoundMgmt_Routing_Confirm}
    Wait For Elements State    ${Project_RoundMgmt_Routing_Confirm_Approve}    enabled    30
    Click    ${Project_RoundMgmt_Routing_Confirm_Approve}
    Wait For Elements State     //td[.="APAC"]/../td[.="Confirmed"]
    Wait Until Search Finished

Step ${step} Select APAC Click On Download Check The Downloaded File
    #************************Step 29******************************
    #  Do:
    #      Select APAC click on Download check the downloaded file
    #  Expected:
    #      index php attachments get 2ee9bc75 9e34 44a2 b478
    #     9dc39f293f19
    #************************************************************
    Click    xpath=//div//tr[td//text()[contains(.,"APAC")]]//input[@type='checkbox']
    Sleep    2
    ${filename}    Download File    ${Project_RoundMgmt_Routing_Download}
    Set Test Variable    ${filename}    ${filename}
    Wait Until Search Finished

    Open Excel Document     ${filename}    Sheet0
    Check Cell Value    2    13    SHE    AIR
    Check Cell Value    2    14    SHE    AIR
    Check Cell Value    2    15    JFK    AIR
    Check Cell Value    2    16    EWR    AIR

    Check Cell Value    3    13    BER    AIR
    Check Cell Value    3    14    FRA    AIR
    Check Cell Value    3    15    AUU    AIR
    Check Cell Value    3    16    AUU    AIR
    Close Current Excel Document


Step ${step} Close This Dialog In Round Management Page Download IPT
    #************************Step 30******************************
    #  Do:
    #      Close this dialog in round management page download IPT
    #     check the file
    #  Expected:
    #      index php attachments get cca52f0c 8f4a 4c15 821e
    #     e969ce1d88bd
    #************************************************************
    Click    ${Dialog_Close}
    ${filename}    Download File    ${Project_RoundMgmt_DownloadButton}
    Set Test Variable    ${filename}    ${filename}
    Wait Until Search Finished

    Open Excel Document     ${filename}    Sheet0
    Check Cell Value    5    34    Door    AIR_D
    Check Cell Value    5    35    SHE    AIR_D
    Check Cell Value    5    36    SHE    AIR_D
    Check Cell Value    5    37    JFK    AIR_D
    Check Cell Value    5    38    EWR    AIR_D
    Check Cell Value    5    39    Door    AIR_D

    Check Cell Value    6    34    Airport    AIR_D
    Check Cell Value    6    35    BER    AIR_D
    Check Cell Value    6    36    FRA    AIR_D
    Check Cell Value    6    37    AUU    AIR_D
    Check Cell Value    6    38    AUU    AIR_D
    Check Cell Value    6    39    Airport    AIR_D
    Close Current Excel Document
    Close Browser

Step ${step} Login As NATZHANG Open This Project Round Management
    #************************Step 31******************************
    #  Do:
    #      Login as NATZHANG Open this project round management
    #     change the role to Regional Pricing Manager EUROPE click
    #     on Routing Confirmation download file
    #  Expected:
    #      index php attachments get 258f4dad e8fa 4c20 9944
    #     6bd19e9ce1b9
    #************************************************************
    Remove All Files
    Set Global Variable    ${USERNAME}    NATZHANG
    Login Space
    Search Project    ${PROJECT.TENDER_ID}
    Wait Until Search Finished
    Wait Until Keyword Succeeds    10x    500ms    Click    ${Project_toolbar_RoundMgmtButton}
    # Wait For Elements State    ${Project_RoundMgmt_CurrentRole}    enabled    60
    # Wait Until Keyword Succeeds    10x    500ms    Select Options By   ${Project_RoundMgmt_CurrentRole}    label    Regional Pricing Manager(EUROPE)
    Wait For Elements State    //div[@ng-click="toggleDropdown()"]
    Click    //div[@ng-click="toggleDropdown()"]
    Click    //div[contains(text(),"Regional Pricing Manager(EUROPE)")]

Step ${step} Modify It As
    #************************Step 32******************************
    #  Do:
    #      Modify it as
    #      index php attachments get 694b5016 166c 40c5 9f58
    #     a7eff69d941e
    #      Upload it
    #  Expected:
    #      Uploaded Successfully is displayed
    #************************************************************
    Click    ${Project_RoundMgmt_RoutConfirmButton}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_Download}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_Upload}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_Cancel}
    ${filename}    Download File    ${Project_RoundMgmt_Confirm_Download}
    Set Test Variable    ${filename}    ${filename}
    Wait Until Search Finished

    Open Excel Document     ${filename}    Sheet0
    Write Excel Cell    2    13    FRA    AIR
    Write Excel Cell    2    14    BER    AIR
    Write Excel Cell    2    15    AUU    AIR
    Write Excel Cell    2    16    AUU    AIR
    Save Excel Document    ${filename}
    Close Current Excel Document
    Click     ${Project_RoundMgmt_Confirm_Upload}
    Wait For Elements State    ${Project_RoundMgmt_Confirm_UploadAddFile}    visible    10
    Upload File By Selector    ${upload_addFileButton}    ${filename}
    Wait Until Search Finished
    Wait For Elements State    ${Project_RoundMgmt_Setup_UploadAddFile_OKButton}    visible    60
    Click    ${Project_RoundMgmt_Setup_UploadAddFile_OKButton}
    Remove File   ${filename}
    Close Browser

Step ${step} Login As WENDJIAN Again Open This Project Round
    #************************Step 33******************************
    #  Do:
    #      Login as WENDJIAN again Open this project round
    #     management dialog click on Routing Confirmation
    #      Select EUROPE click on Confirm button
    #      In the pop up window click on Reject button
    #  Expected:
    #      The state of EUROPE is Rejected
    #************************************************************
    Remove All Files
    Set Global Variable    ${USERNAME}    WENDJIAN
    Login Space
    Search Project    ${PROJECT.TENDER_ID}
    Wait Until Search Finished
    Wait Until Keyword Succeeds    10x    500ms    Click    ${Project_toolbar_RoundMgmtButton}
    Wait Until Keyword Succeeds    5x    100ms    Click    ${Project_RoundMgmt_RoutConfirmButton}    
    Click    xpath=//div//tr[td//text()[contains(.,"EUROPE")]]//input[@type='checkbox']
    Click    ${Project_RoundMgmt_Routing_Confirm}
    Wait For Elements State    ${Project_RoundMgmt_Routing_Confirm_Reject}    enabled    30
    Click    ${Project_RoundMgmt_Routing_Confirm_Reject}
    Wait For Elements State     //td[.="EUROPE"]/../td[.="Rejected"]
    Wait Until Search Finished

Step ${step} Close This Window In Round Management Download IPT
    #************************Step 34******************************
    #  Do:
    #      Close this window in round management download IPT
    #  Expected:
    #      index php attachments get f068b2ba 602f 4a8b 8bfb
    #     e9996fd49769
    #************************************************************
    Click    ${Dialog_Close}
    ${filename}    Download File    ${Project_RoundMgmt_DownloadButton}
    Set Test Variable    ${filename}    ${filename}
    Wait Until Search Finished

    Open Excel Document     ${filename}    Sheet0
    Check Cell Value    5    34    Door    AIR_D
    Check Cell Value    5    35    SHE    AIR_D
    Check Cell Value    5    36    SHE    AIR_D
    Check Cell Value    5    37    JFK    AIR_D
    Check Cell Value    5    38    EWR    AIR_D
    Check Cell Value    5    39    Door    AIR_D

    Check Cell Value    6    34    Airport    AIR_D
    Check Cell Value    6    35    BER    AIR_D
    Check Cell Value    6    36    FRA    AIR_D
    Check Cell Value    6    37    AUU    AIR_D
    Check Cell Value    6    38    AUU    AIR_D
    Check Cell Value    6    39    Airport    AIR_D
    Close Current Excel Document

Step ${step} Click On Close Button
    #************************Step 35******************************
    #  Do:
    #      Click on Close button
    #      In Pricing Project page User selects TenderID Contains
    #     20240815
    #  Expected:
    #      The project could be found
    #************************************************************
    Click    //button[.="Close"]
    Wait For Elements State    //td[contains(text(),"${G_TENDERID}")]

Step ${step} Select This Project Click On Delete Project Button
    #************************Step 36******************************
    #  Do:
    #      Select this project click on Delete Project button
    #      Click Yes of the pop up confirm window
    #  Expected:
    #      System displays Project has been deleted
    #************************************************************
    # stop round first before removing the project
    Click    //td[contains(text(),"${G_TENDERID}")]
    Wait Until Keyword Succeeds    10x    500ms    Click    ${Project_toolbar_RoundMgmtButton}
    Click    ${Project_RoundMgmt_CloseRoundButton}
    Click    //button[contains(text(),"Yes")]
    Wait Until Search Finished
    Click    //button[.="Close"]
    # Data Cleaning
    Click    //td[contains(text(),"${G_TENDERID}")]
    Click    ${Project_toolbar_DataCleaningButton}
    Click    //button[contains(., "Yes")]
    Wait For Elements State    ${Data_toolbar_UploadButton}    visible    30
    Click    ${Data_toolbar_CloseButton}
    Click    //button[contains(., "Yes")]
    Delete Project    ${G_TENDERID}

Step ${step} User Goes To Basic Data Management Tender List 37
    #************************Step 37******************************
    #  Do:
    #      User goes to Basic Data Management Tender List
    #      Search out the tender created in step1
    #      Click on Delete button
    #      Click on Yes button in the popup dialog
    #  Expected:
    #      System displays Tender has been deleted
    #************************************************************
    Delete Tender    ${G_TENDERID}
    Set Global Variable    ${USERNAME}    AUTOTEST
